package com.igeekhome.ccs.controller;

import com.igeekhome.ccs.biz.ICommonWordsBiz;
import com.igeekhome.ccs.biz.ICommonWordsCategoryBiz;
import com.igeekhome.ccs.entity.CommonWords;
import com.igeekhome.ccs.entity.CommonWordsCategory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
@RequestMapping("/cmg")
public class CommonWordsCategoryController {
 //👇zyh----------------------------------------------
 @Autowired
    ICommonWordsCategoryBiz biz;

    //提供公共库所有分类对象
    @GetMapping("/queryPublicLib")
    public @ResponseBody
    List<CommonWordsCategory> queryPublicLib() {
        return  biz.queryPublicLib();
    }

    //提供个人库所有分类对象
    @GetMapping("/queryPrivateLib")
    public @ResponseBody
    List<CommonWordsCategory> queryPrivateLib(@RequestParam("csId") int csId) {
        return  biz.queryPrivateLib(csId);
    }

    //通过分类ID拿到所有常用语对象
    @GetMapping("/queryCwByCategoryId")
    public @ResponseBody
    List<CommonWords> queryCwByCategoryId(@RequestParam("categoryId") int categoryId) {
        return  biz.queryCwByCategoryId(categoryId);
    }

    //新增分类
    @PostMapping("/createCwc")

    public  @ResponseBody
    int createCwc(@RequestBody CommonWordsCategory commonWordsCategory){
        return  biz.createCwc(commonWordsCategory);
    }


 //👆zyh----------------------------------------------
}
